var express = require('express');
var router = express.Router();
/********************黄涛**************************/
const {
    getLessors,
    modifyLessors,
    deleteLessors,
    EditLessors
    
} = require("../service/adminsService");
const {
    getTenants,
    modifyTenants,
    deleteTenants,
    EditTenants
} = require("../service/adminsService");

const {
 
    getParkings,
    modifyParkings,
    deleteParkings,
    EditParkings
} = require("../service/adminsService");

//配置出租方
router.post('/getLessors', async function (req, res, next) {
    const data = await getLessors(req.body);
    res.send(data);/*  */
});
router.post('/modifyLessors', async function (req, res, next) { //单独改出租方的state状态
    const data = await modifyLessors(req.body);
    res.send(data);
});
router.post('/EditLessors', async function (req, res, next) { 
    const data = await EditLessors(req.body);
    res.send(data);
});

router.post("/deleteLessors", async function (req, res, next) {
    const data = await deleteLessors(req._id);
    res.send(data);
})

//配置车位
router.post('/getParkings', async function (req, res, next) {
    const data = await getParkings(req.body);
   res.send(data)
})
router.post('/modifyParkings', async function (req, res, next) { //单独改出租方的state状态
    const data = await modifyParkings(req.body);
    res.send(data);
});

router.post('/EditParkings', async function (req, res, next) { //单独改出租方的state状态
    const data = await EditParkings(req.body);
    res.send(data);
});

router.post("/deleteParkings", async function (req, res, next) {
    const data = await deleteParkings(req._id);
    res.send(data);
})
//租客的配置
router.post('/getTenants', async function (req, res, next) {
    const data = await getTenants(req.body);
    res.send(data);
});

router.post('/modifyTenants', async function (req, res, next) {
    const data = await modifyTenants(req.body);
    res.send(data);

});

router.post('/EditTenants', async function (req, res, next) { //单独改出租方的state状态
    const data = await EditTenants(req.body);
    res.send(data);
});

router.post("/deleteTenants", async function (req, res, next) {
    const data = await deleteTenants(req._id);
    res.send(data);
})
/********************黄涛**************************/    




/*********************练超开始**************************/
const {getAdmins,deleteAdmins,forbidAdmins,addAdmins,modifyAdmins,isAdmins,seekAdmins} = require('../service/adminsService');

//配置二级路径

//获取管理员数据
router.get('/getAdmins',async function(req, res, next) {
    const data = await getAdmins(req.query);
    res.send(data)
});

//删除管理员
router.post('/deleteAdmins',async function(req, res, next) {
    const data = await deleteAdmins(req.body);
    res.send(data);
});

//禁用或启用管理员
router.post('/forbidAdmins',async function(req, res, next) {
    const data = await forbidAdmins(req.body);
    res.send(data);
});

//新增管理员
router.post('/addAdmins',async function(req, res, next) {
    const data = await addAdmins(req.body);
    res.send(data);
});

//修改管理员数据
router.post('/modifyAdmins',async function(req, res, next) {
    const data = await modifyAdmins(req.body);
    res.send(data);
});

//验证管理员账号
router.post('/isAdmins',async function(req, res, next) {
    const data = await isAdmins(req.body);
    res.send(data);
});

//查找管理员
router.post('/seekAdmins',async function(req, res, next) {
    const data = await seekAdmins(req.body);
    res.send(data);
});

/*******************练超结尾******************************/
module.exports = router;
